package org.holynite.fieldmanage.entities

import org.holynite.fieldmanage.types.Payments

import javax.persistence.CascadeType
import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.EnumType
import javax.persistence.Enumerated
import javax.persistence.FetchType
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.OneToMany
import javax.persistence.Table
import javax.persistence.Temporal
import javax.persistence.TemporalType
import javax.persistence.Transient
import java.sql.Timestamp

/**
 * Created by midnite on 15/1/5.
 */
@Entity
@Table(name = "commodity_consume_record")
class CommodityConsumeRecord implements Serializable {
	@Id
	@Column(name = "comm_consume_serial")
	String serial
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "con_time")
	Date consumeTime
	@Column(name = "venue_name")
	String venueName
	@Column(name = "customer_name")
	String customerName
	@Column(name = "total_discount")
	String totalDiscount
	@Column(name = "total_price")
	String totalPrice
	@Enumerated(EnumType.STRING)
	@Column(name = "payment")
	Payments payment
	@Column(name = "collect")
	Float collect
	@Column(name = "change")
	Float change
	@Column(name = "refund")
	Boolean refund
	@Transient
	Set<CommodityConsumeRecordDetail> details

	boolean equals(o) {
		if (this.is(o)) return true
		if (getClass() != o.class) return false

		CommodityConsumeRecord that = (CommodityConsumeRecord) o

		if (serial != that.serial) return false

		return true
	}

	int hashCode() {
		return (serial != null ? serial.hashCode() : 0)
	}
}
